package com.awcall.iot.controller;


import com.awcall.iot.common.ResponseResult;
import com.awcall.iot.model.Setting;
import com.awcall.iot.service.ISettingService;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import com.awcall.iot.common.BaseController;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wuhui
 * @since 2018-03-22
 */
@RestController
@RequestMapping("/admin/setting")
public class SettingController extends BaseController {

    @Autowired
    private ISettingService iSettingService;

    @PostMapping("/update")
    public ResponseResult update(@RequestBody Setting setting){

        EntityWrapper<Setting> entityWrapper = new EntityWrapper<>();
        entityWrapper.eq(Setting.KEY,setting.getsKey());
        boolean update = iSettingService.update(setting, entityWrapper);
        if (update) {
            return new ResponseResult();
        } else {
            return new ResponseResult(1, "失败");
        }
    }

}
